package com.thenie.service.impl;

import com.thenie.mapper.DeptMapper;
import com.thenie.pojo.Dept;
import com.thenie.service.DeptService;
import com.thenie.vo.DeptVo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.sql.Timestamp;
import java.util.Date;
import java.util.List;

@Service
@Transactional
public class DeptServiceImpl implements DeptService {
    /**
     * 查询部门列表
     * @param deptVo
     * @return
     */
    @Resource
    private DeptMapper deptMapper;

    public List<Dept> findDeptListByPage(DeptVo deptVo) {
        return deptMapper.findDeptListByPage(deptVo);
    }

    /**
     * 添加部门
     * @param dept
     * @return
     */
    public int addDept(Dept dept){
        dept.setCreateDate(new Date());
//        Timestamp timestamp = new Timestamp(new Date().getTime());
//        dept.setCreateDate(timestamp);
        return deptMapper.insertDept(dept);
    }

    /**
     * 修改部门
     */
    public int updateDept(Dept dept){
        return deptMapper.updateDept(dept);
    }
    /**
     * 删除部门
     * @param id
     * @return
     */
    public int deleteDeptById(int id){
        return deptMapper.deleteDeptById(id);
    }


}
